package kr.hkit.powerjava.chapter21.work;
import java.util.Scanner;


public class ExceptionTest {
	public static void main(String[] args) {
		int[] list = null;
		int sum=0;
		int count = 0;
		Scanner sc = null;
		try{
			
		sc=new Scanner(System.in);
		
		}catch(NullPointerException e){
			System.out.println("NULL 객체를 참조 할수 없음");
		}
		
		System.out.print("정수의 개수 : ");
		try{
		count = sc.nextInt();
		list= new int [count];
		}catch (NegativeArraySizeException e) {
	System.out.println("양수를입력하시오");
		}
		for (int i = 0; i < count; i++) {
			System.out.print("정수를 입력하시오 : ");
			try{
			list[i]=sc.nextInt();
			}catch(ArrayIndexOutOfBoundsException e){
				System.out.println("배열을 참조할수 없음");
			}
		}
		for (int i = 0; i < count; i++) {
			sum=sum+list[i];
		}
		try{
		System.out.print("평균은 : "+sum/count);
		}catch(ArithmeticException e){
			System.out.println("0 은입력할 수 없습니다.");
		}
	}

}
